<template>
  <div class="wrap" id="children">
    <el-dialog
      title="编辑"
      :visible.sync="state"
      @close="close"
      :close-on-click-modal="false"
      :close-on-press-escape="false"
    >
      <el-form>
        <el-form-item label="设置头像" :label-width="formLabelWidth">
          <el-upload
            class="avatar-uploader"
            action="/"
            :show-file-list="false"
            :on-success="handleAvatarSuccess"
          >
            <img v-if="imageUrl" :src="imageUrl" class="avatar" />
            <i v-else class="el-icon-plus avatar-uploader-icon"></i>
          </el-upload>
        </el-form-item>
        <el-form-item label="编辑名称" :label-width="formLabelWidth">
          <el-input autocomplete="off" placeholder="请输入名称"></el-input>
        </el-form-item>
        <el-form-item label="编辑收款人账号" :label-width="formLabelWidth">
          <el-input autocomplete="off"  placeholder="请输入收款人账号"></el-input>
        </el-form-item>
        <el-form-item label="编辑登陆密码" :label-width="formLabelWidth">
          <el-input autocomplete="off"  placeholder="请输入登陆密码"></el-input>
        </el-form-item>
        <el-form-item label="手机号" :label-width="formLabelWidth">
          <el-input autocomplete="off"  placeholder="请输入手机号"></el-input>
        </el-form-item>
        <el-form-item label="手机验证码" :label-width="formLabelWidth">
          <el-input autocomplete="off" placeholder="请输入手机验证码"></el-input>
           <el-button type="primary" size="mini">发送验证码</el-button>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="close">取 消</el-button>
        <el-button type="primary" @click="close(1)">确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>
<script>
export default {
  props: {
    userState: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {
      formLabelWidth: "140px",
      imageUrl: ""
    };
  },
  computed: {
    state: {
      get() {
        return this.userState;
      },
      set() {}
    }
  },
  methods: {
    close(v) {
      if (v) {
        this.$emit("getUser");
      } else {
        this.$emit("getUser");
      }
    },
    handleAvatarSuccess(res, file) {
        console.log(file)
      this.imageUrl = URL.createObjectURL(file.raw);
    },
  }
};
</script>
<style lang="scss" scoped>
.el-input {
  width: 240px;
}
.el-dialog {
  width: 50% !important;
}
</style>
<style lang="scss">
#children .el-dialog {
  width: 40% !important;
}
.avatar-uploader .el-upload {
  border: 1px dashed #d9d9d9;
  border-radius: 6px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.avatar-uploader .el-upload:hover {
  border-color: #409eff;
}
.avatar-uploader-icon {
  font-size: 28px;
  color: #8c939d;
  width: 178px;
  height: 178px;
  line-height: 178px;
  text-align: center;
}
.avatar {
  width: 178px;
  height: 178px;
  display: block;
}
</style>